package com.aaa.whj.controller;

import com.aaa.whj.entity.Dept;
import com.aaa.whj.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: whj
 * @Version 1.0
 * @Date: 2022/12/7  15:06
 */
@RestController
@RequestMapping("dept")
public class DeptController {
    @Autowired
    private DeptService deptService;

    @GetMapping("/{id}")
    public Dept selectById(@PathVariable Integer id){
        return deptService.selectById(id);
    }

    @DeleteMapping("/{id}")
    public Integer delete(@PathVariable Integer id){
        return deptService.delete(id);
    }

    @PostMapping
    public Dept save(@RequestBody Dept dept){

        return deptService.add(dept);
    }

    @PutMapping
    public Dept update(@RequestBody Dept dept){
        return deptService.update(dept);
    }
}
